from abc import ABC, abstractmethod


class Car(ABC):
    @abstractmethod
    def drive(self):
        pass


class SportsCar(Car):
    def drive(self):
        return 'SportsCar driving!'


class Truck(Car):
    def drive(self):
        return 'Truck driving!'


class CarFactory(ABC):
    @abstractmethod
    def create_sports_car(self):
        pass

    @abstractmethod
    def create_truck(self):
        pass


class ConcreteCarFactory(CarFactory):
    def create_sports_car(self):
        return SportsCar()

    def create_truck(self):
        return Truck()


# 客户端代码
factory = ConcreteCarFactory()
car1 = factory.create_sports_car()
car2 = factory.create_truck()
print(car1.drive())
print(car2.drive())

'''
SportsCar driving!
Truck driving!
'''